Override draw_layout method in GtkStyle in order to adjust by 2 pixels any
authorCody Russell <bratsche@gnome.org>
Thu, 20 Sep 2007 16:51:16 +0000 (16:51 +0000)
committerCody Russell <bratsche@src.gnome.org>
Thu, 20 Sep 2007 16:51:16 +0000 (16:51 +0000)
2007-09-20  Cody Russell  <bratsche@gnome.org>

        * modules/engines/ms-windows/msw_style.c: Override draw_layout
        method in GtkStyle in order to adjust by 2 pixels any labels
        that are in GtkNotebook tabs using XP theme, so that they appear
        correctly centered. (#478637)

svn path=/trunk/; revision=18848

ChangeLog
modules/engines/ms-windows/msw_style.c

index de22212cfb085897de5ead7b1aa9f858698c3ee5..453c907d0b0f26ef062cb78f69582edca43c8788 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2007-09-20  Cody Russell  <bratsche@gnome.org>
+
+       * modules/engines/ms-windows/msw_style.c: Override draw_layout
+       method in GtkStyle in order to adjust by 2 pixels any labels
+       that are in GtkNotebook tabs using XP theme, so that they appear
+       correctly centered. (#478637)
+
 2007-09-18  Emmanuele Bassi  <ebassi@gnome.org>
 
        * gtk/gtksearchenginetracker.c: Search libtrackerclient.so.0
index 2b0e822b183400341bdf45af10d7cd309b8b4839..9b61f590ab46897b72f82116a3e6482cc73c7ad3 100755 (executable)
@@ -3251,6 +3251,48 @@ draw_focus ( GtkStyle      *style,
 */
 }
 
+static void
+draw_layout (GtkStyle        *style,
+            GdkWindow       *window,
+            GtkStateType     state_type,
+            gboolean         use_text,
+            GdkRectangle    *area,
+            GtkWidget       *widget,
+            const gchar     *detail,
+            gint             old_x,
+            gint             old_y,
+            PangoLayout     *layout)
+{
+    GtkNotebook *notebook = NULL;
+    gint x = old_x;
+    gint y = old_y;
+
+    /* In the XP theme, labels don't appear correctly centered inside
+     * notebook tabs, so we give them a gentle nudge two pixels to the
+     * right.  A little hackish, but what are 'ya gonna do?  -- Cody
+     */
+    if (xp_theme_is_active () && detail && !strcmp (detail, "label"))
+      {
+       if (widget->parent != NULL)
+         {
+           if (GTK_IS_NOTEBOOK (widget->parent))
+             {
+               notebook = GTK_NOTEBOOK (widget->parent);
+               int side = gtk_notebook_get_tab_pos (notebook);
+
+               if (side == GTK_POS_TOP || side == GTK_POS_BOTTOM)
+                 {
+                   x += 2;
+                 }
+             }
+         }
+      }
+
+    parent_class->draw_layout (style, window, state_type,
+                              use_text, area, widget,
+                              detail, x, y, layout);
+}
+
 static void
 msw_style_init_from_rc (GtkStyle * style, GtkRcStyle * rc_style)
 {
@@ -3404,6 +3446,7 @@ msw_style_class_init (MswStyleClass * klass)
     style_class->draw_resize_grip = draw_resize_grip;
     style_class->draw_slider = draw_slider;
     style_class->draw_focus = draw_focus;
+    style_class->draw_layout = draw_layout;
 
     style_class->realize = msw_style_realize;
     style_class->unrealize = msw_style_unrealize;